import config from 'config'
import hprose from 'hprose-html5'
let _self = window
export default {
  install (vue) {
    let url = config.urls['business']
    console.log('api service: ', url)
    let client = new hprose.HttpClient(url)
    let tokenHandler = (name, args, context, next) => {
      let token = _self.$cache.get('session_token')
      args.push(token)
      return next(name, args, context)
    }
    client.use(tokenHandler)
    window.$co = vue.prototype.$co = hprose.co
    window.$rpc = vue.prototype.$rpc = client
  }
}
